package study.java.thread03;

/**
* @Name: SellTicketRunnable
* @Description: 多线程练习（实现Runnable接口）
* @Author: 李超	lc_jack@foxmail.com
* @CreateDate: 2017-1-8 下午10:07:39 
* @Version: V1.0
 */
public class SellTicketRunnable implements Runnable {
	
	//创建100张票
	private int tickets = 100 ;

	@Override
	public void run() {
		while(true) {
			if(tickets > 0) {
				System.out.println(Thread.currentThread().getName() + "正在出售第[" + (tickets--) + "]张票");
				try {
					//每卖一张票，休眠0.1秒
					Thread.sleep(100) ; 
				} catch (InterruptedException e) {
					e.printStackTrace();
				}
			}
		}
	}

}
